import * as service from '../../services/traceService';
export default {
  namespace: 'traceMgr',
  state: {
    queryRes: {
      code: "",
      execInfo: [],
      matInfo:{},
      prodTraceInfo:{},
      deliveryTraceInfo:[]
    }
  },
  reducers: {
    showQueryRes(state, { payload: { res } }) {
      return { ...state, queryRes: res };
    }
  },
  effects: {
    *queryCode({ payload: { code } }, { call, put }) {
      const res = yield call(service.QueryCode, code);
      if (res != null&&res.success) {
        yield put({
          type: 'showQueryRes',
          payload: {
            res: res.result
          }
        })
      }
      else{
        console.warn(res.error);
        yield put({
          type: 'showQueryRes',
          payload: {
            res: {code:'',execInfo:[]}
          }
        })
      }
    }
  },
  subscriptions: {},
};
